using System;
using System.Collections.Generic;
using System.Windows.Forms;
using Cliente.Forms;
using Cliente.Objetos;

namespace Cliente
{
    static class Program
    {
		/// <summary>
		/// The main entry point for the application.
		/// </summ  1ary>
		[STAThread]
		static void Main()
		{
			try
			{
				Application.EnableVisualStyles();

                using (TelaLogin login = new TelaLogin())
				{
                    MainForm oForm = new MainForm();
                    App.oMainForm = oForm;

					//if (login.ShowDialog() == DialogResult.OK)
                    if (true)
					{
                        oForm.Show();
					}
					else
					{
						Application.Exit();
						return;
					}

				}

				// In production, turn this on
				//Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException );
				//Application.ThreadException += new System.Threading.ThreadExceptionEventHandler(Application_ThreadException);

                ApplicationContext _Context = new ApplicationContext();
				Application.DoEvents();
                Application.Run(_Context);
			}
			catch (Exception x)
			{
                // Logo o x.string

                // mostro a excecao melhorzinha
                UIHelper.DlgErro(x.Message);
			}

		}

		static void Application_ThreadException(object sender, System.Threading.ThreadExceptionEventArgs e)
		{
			MessageBox.Show(e.Exception.Message, "Error Occured", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
		}
    }
}